package com.blumov.fastbox.application.services.servicelocator;

import com.blumov.fastbox.application.services.compra.PedidoService;
import com.blumov.fastbox.application.services.configuration.ApplicationContainer;
import com.blumov.fastbox.domain.model.compra.PedidoRepository;
import com.blumov.fastbox.domain.model.producto.ProductoRepository;

public class ServiceLocatorImpl implements ServiceLocator {

	public PedidoService getPedidoService() {
		ApplicationContainer instance = getAnInstanceOfApplicationContainer();
		return (PedidoService) instance.getService(ServiceNames.PEDIDO_SERVICE);
	}

	public PedidoRepository getPedidoRepository() {
		ApplicationContainer instance = getAnInstanceOfApplicationContainer();
		return (PedidoRepository) instance.getService(ServiceNames.PEDIDO_REPOSITORY);
	}
	
	public ProductoRepository getProductoRepository() {
		ApplicationContainer instance = getAnInstanceOfApplicationContainer();
		return (ProductoRepository) instance.getService(ServiceNames.PRODUCTO_REPOSITORY);
	}
	
	/**
	 * @return a instance of the application container
	 */
	ApplicationContainer getAnInstanceOfApplicationContainer() {
		ApplicationContainer instance = ApplicationContainer.getInstance();
		return instance;
	}
}
